﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using IQKS.AWP.BusinessObject;
using System.Web.Security;

namespace IQKS.AWP.DataAccessLayer
{
    public class UserMasterDAL
    {
        public DataSet GetCandidateRemaining(params object[] param)
        {
            DataSet objDs;


            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetCandidateRemainingPayment", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }
        public DataSet GetCandidateMasterNew(params object[] param)
        {
            DataSet objDs;


            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetCandidateMasterNew", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }
        public DataSet GetUserMaster(params object[] param)
        {
            DataSet objDs;


            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetUserMaster", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetUserNameByRole(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetUserNameByRole", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetCandidateDetails(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetCandidateForPayment", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetCandidatedetailReg(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetCandidateRegByCandidateId", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetStatusDashboard(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetStatusDashboardUserWise", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetAssessorCalenderDashboard(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("usp_GETAssessorDashboardCalender", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetStatusDashboardbyStatusId(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetStatusDashboardbyStatusId", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetStatusDashboardbyAssigningAssessor(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetStatusDashboardbyAssigningAssessor", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetStatusDashboardbyAllocatedAssessor(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetStatusDashboardbyAllocatedAssessor", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetAssessorByRole(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetAssessorByRole", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetAssessorLocationFees(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetAssessorLocationFees", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetUserLogin(params object[] param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetUserLogin", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }
        public DataSet GetAssessorDaysForAdmin()
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("usp_GetAssessorBookedDatesForAdmin");

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public object SetUserMaster(UserMasterBO param)
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
			    {      
                    
                    new SqlParameter("@UpdateUserID",param.UserID),
                    new SqlParameter("@EmailID",param.EmailID),
                    new SqlParameter("@FirstName",param.FirstName),
                    new SqlParameter("@MiddleName",param.MiddleName),
                    new SqlParameter("@LastName",param.LastName),
                    new SqlParameter("@ProfilePicturePath",param.ProfilePicturePath),
                    new SqlParameter("@Gender",param.Gender),
                    new SqlParameter("@DOB",param.DOB),
                    new SqlParameter("@CreatedBy",param.CreatedBy),
                    new SqlParameter("@ModifyBy",param.ModifyBy),
                    new SqlParameter("@SetMethod",param.SetMethod),
 
                    new SqlParameter("@CountryID",param.CountryID),
                    new SqlParameter("@StateName",param.StateName),
                    new SqlParameter("@ContactAddress",param.Address),
                    new SqlParameter("@ZipCode",param.ZipCode),
                    new SqlParameter("@PhoneNo",param.WorkPhoneNo),
                    new SqlParameter("@MobileNo",param.MobileNo),
                    new SqlParameter("@OtherPhoneNo",param.OtherPhoneNo),
                    new SqlParameter("@GraduationID",param.Graduation),
                    new SqlParameter("@QualificationSpecialization",param.Specialization),
                    new SqlParameter("@University",param.University),
                    new SqlParameter("@QualificationStatusID",param.Status),
                    new SqlParameter("@Fees",param.Fees),
                    new SqlParameter("@PaymentMode",param.PaymentMode),
                    new SqlParameter("@BankName",param.BankName),
                    new SqlParameter("@BankCode",param.BankCode),
                    new SqlParameter("@SWIFTCode",param.SWIFTCode),
                    new SqlParameter("@AccountNo",param.AccountNo),
                    new SqlParameter("@UserCompanyDetail",param.UserCompanyDetail),
                    
                    new SqlParameter("@RCountryID",param.RCountryID),
                    new SqlParameter("@RegionID",param.RegionID),
                    new SqlParameter("@CountryHeadID",param.CountryHeadID),

                   new SqlParameter("@ReturnValue",param.StatusMessage),
                   new SqlParameter("@AssessorLocationFeesDetail",param.AssessorLocationFeesDetail)
                   
                };


                MembershipCreateStatus status;
                MembershipUser User;
                if (param.SetMethod == "INSERT")
                {
                    User = Membership.CreateUser(param.EmailID.Trim(), param.Password.Trim(), param.EmailID.Trim(), param.Secret.Trim(), param.Answer.Trim(), param.IsActive, out status);

                    if (User == null)
                    {
                        param.StatusMessage = GetErrorMessage(status);
                        return param.StatusMessage.ToString();
                    }
                    else
                    {
                        Roles.AddUserToRole(param.EmailID.Trim(), param.RoleName);
                        //param.StatusMessage = "Success";
                        object result = DataUtils.ExecuteScalar("Usp_SetUserMaster", parameters).ToString(); ;
                        return result;
                    }
                }
                else
                {
                    object result = DataUtils.ExecuteScalar("Usp_SetUserMaster", parameters).ToString(); ; //update parameter
                    return result;
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }

        public string SetDefaultPassword(Guid userguid)
        {
            string valid = "Fail";
            try
            {
                MembershipUser User;
                MembershipProvider MSP = Membership.Providers["MembershipProvider"];
                User = MSP.GetUser(userguid, false);
                User.UnlockUser();
                string DefaultPassword = System.Configuration.ConfigurationManager.AppSettings["DefaultPassword"].ToString();
                User.ChangePassword(User.ResetPassword(), DefaultPassword);
                valid = "Success";
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
            return valid;
        }

        public object SetCandidateMaster(UserMasterBO objUserBO, CandidateMasterBO objCandidateMasterBO, UsersContactBO objUsersContactBO, UsersQualificationBO objUsersQualificationBO)
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
			    {  
                    new SqlParameter("@ApplicationName",objUserBO.ApplicationName),   
                    new SqlParameter("@RoleNames",objUserBO.RoleName),
                    new SqlParameter("@CandidateMode",objUserBO.SetMethod),
                    new SqlParameter("@UserID",objUserBO.UserID),
                    new SqlParameter("@AccrediationTypeCode",objCandidateMasterBO.AccrediationTypeCode),
                    new SqlParameter("@CandidateTypeCode",objCandidateMasterBO.CandidateTypeCode),
                    new SqlParameter("@MarketResearchCompanyName", objCandidateMasterBO.MarketResearchCompany ),
                    new SqlParameter("@UserName",objUserBO.EmailID),
                    new SqlParameter("@Password",objUserBO.Password),
                    new SqlParameter("@PasswordSalt",objUserBO.Password),
                    new SqlParameter("@PasswordQuestion",objUserBO.SecretQuestion),
                    new SqlParameter("@PasswordAnswer",objUserBO.SecretAnswer),
                    new SqlParameter("@IsApproved",objUserBO.IsApproved),
                    new SqlParameter("@CurrentTimeUtc",objUserBO.CreatedDate),
                    new SqlParameter("@CreatedBy",objUserBO.CreatedBy),
                    new SqlParameter("@ModifyBy",objUserBO.ModifyBy),
                    new SqlParameter("@CountryID",objUsersContactBO.CountryID),
                    new SqlParameter("@NationalityID",objUserBO.NationalityID),
                    new SqlParameter("@FirstName",objUserBO.FirstName),
                    new SqlParameter("@MiddleName",objUserBO.MiddleName),
                    new SqlParameter("@LastName",objUserBO.LastName),
                    new SqlParameter("@ProfilePicturePath",objUserBO.ProfilePicturePath),
                    new SqlParameter("@Gender",objUserBO.Gender),
                    new SqlParameter("@DOB",objUserBO.DOBirth),
                    new SqlParameter("@CVPath",objCandidateMasterBO.CVPath),
                    new SqlParameter("@StateName",objUsersContactBO.StateName),
                    new SqlParameter("@ContactAddress",objUsersContactBO.ContactAddress),
                    new SqlParameter("@ZipCode",objUsersContactBO.ZipCode),
                    new SqlParameter("@PhoneNo",objUsersContactBO.PhoneNo),
                    new SqlParameter("@MobileNo",objUsersContactBO.MobileNo),
                    new SqlParameter("@OtherPhoneNo",objUsersContactBO.OtherPhoneNo),
                    new SqlParameter("@GraduationID",objUsersQualificationBO.GraduationID),
                    new SqlParameter("@QualificationSpecialization",objUsersQualificationBO.QualificationSpecialization) ,
                    new SqlParameter("@University",objUsersQualificationBO.University) ,
                    new SqlParameter("@QualificationStatusID",objUsersQualificationBO.QualificationStatusID),
                    
                    new SqlParameter("@pProCurrentRole",objUsersQualificationBO.ProCurrentRole),
                    new SqlParameter("@pProExperience",objUsersQualificationBO.ProExperience),
                    new SqlParameter("@pProfQualitative1",objUsersQualificationBO.ProfQualitative1),
                    new SqlParameter("@pProfQualitative2",objUsersQualificationBO.ProfQualitative2),
                    new SqlParameter("@pProfQualitative3",objUsersQualificationBO.ProfQualitative3),
                    new SqlParameter("@pProfQualitative4",objUsersQualificationBO.ProfQualitative4),

                    new SqlParameter("@UserCompanyDetail",objUserBO.UserCompanyDetail) ,
                    new SqlParameter("@LanguageList",objCandidateMasterBO.LanguageList) ,

                    new SqlParameter("@UserApplyBefore",objUsersQualificationBO.UserApplyBefore),
                    new SqlParameter("@ApplyAccrediationType",objUsersQualificationBO.ApplyAccrediationType),
                    new SqlParameter("@FinalResult",objUsersQualificationBO.FinalResult),
                    new SqlParameter("@PassAccrediationType",objUsersQualificationBO.PassAccrediationType),
                    new SqlParameter("@AssessorName",objUsersQualificationBO.AssessorName)
                };

                return DataUtils.ExecuteScalar("Usp_SetCandidateMaster", parameters);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }

        //vivek patil
        public object SetCandidateMasterNew(UserMasterBO objUserBO, CandidateMasterBO objCandidateMasterBO)
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
			    {  
                        new SqlParameter("@SetMethod",objCandidateMasterBO.SetMethod),
                        new SqlParameter("@UserID",objUserBO.UserID),
                        new SqlParameter("@RegistrationNo",objCandidateMasterBO.RegistrationNo), 
                        new SqlParameter("@CandidateID",objCandidateMasterBO.CandidateID) 
                };

                return DataUtils.ExecuteScalar("Usp_SetCandidateMasternew", parameters);

            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }



        public object EditRegisterdCandidateMaster(UserMasterBO objUserBO, CandidateMasterBO objCandidateMasterBO, UsersContactBO objUsersContactBO, UsersQualificationBO objUsersQualificationBO, Int64 cid, string useridcandidate)
        {
            try
            {
                Guid g = new Guid(useridcandidate);
                SqlParameter[] parameters = new SqlParameter[]
			    {  
                    new SqlParameter("@ApplicationName",objUserBO.ApplicationName),   
                    new SqlParameter("@RoleNames",objUserBO.RoleName),
                    new SqlParameter("@CandidateMode",objUserBO.SetMethod),
                    new SqlParameter("@UserID",objUserBO.UserID),
                    new SqlParameter("@AccrediationTypeCode",objCandidateMasterBO.AccrediationTypeCode),
                    new SqlParameter("@CandidateTypeCode",objCandidateMasterBO.CandidateTypeCode),
                    new SqlParameter("@MarketResearchCompanyName", objCandidateMasterBO.MarketResearchCompany ),
                    new SqlParameter("@UserName",objUserBO.EmailID),
                    new SqlParameter("@Password",objUserBO.Password),
                    new SqlParameter("@PasswordSalt",objUserBO.Password),
                    new SqlParameter("@PasswordQuestion",objUserBO.SecretQuestion),
                    new SqlParameter("@PasswordAnswer",objUserBO.SecretAnswer),
                    new SqlParameter("@IsApproved",objUserBO.IsApproved),
                    new SqlParameter("@CurrentTimeUtc",objUserBO.CreatedDate),
                    new SqlParameter("@CreatedBy",objUserBO.CreatedBy),
                    new SqlParameter("@ModifyBy",objUserBO.ModifyBy),
                    new SqlParameter("@CountryID",objUsersContactBO.CountryID),
                    new SqlParameter("@NationalityID",objUserBO.NationalityID),
                    new SqlParameter("@FirstName",objUserBO.FirstName),
                    new SqlParameter("@MiddleName",objUserBO.MiddleName),
                    new SqlParameter("@LastName",objUserBO.LastName),
                    new SqlParameter("@ProfilePicturePath",objUserBO.ProfilePicturePath),
                    new SqlParameter("@Gender",objUserBO.Gender),
                    new SqlParameter("@DOB",objUserBO.DOBirth),
                    new SqlParameter("@CVPath",objCandidateMasterBO.CVPath),
                    new SqlParameter("@StateName",objUsersContactBO.StateName),
                    new SqlParameter("@ContactAddress",objUsersContactBO.ContactAddress),
                    new SqlParameter("@ZipCode",objUsersContactBO.ZipCode),
                    new SqlParameter("@PhoneNo",objUsersContactBO.PhoneNo),
                    new SqlParameter("@MobileNo",objUsersContactBO.MobileNo),
                    new SqlParameter("@OtherPhoneNo",objUsersContactBO.OtherPhoneNo),
                    new SqlParameter("@GraduationID",objUsersQualificationBO.GraduationID),
                    new SqlParameter("@QualificationSpecialization",objUsersQualificationBO.QualificationSpecialization) ,
                    new SqlParameter("@University",objUsersQualificationBO.University) ,
                    new SqlParameter("@QualificationStatusID",objUsersQualificationBO.QualificationStatusID),
                    new SqlParameter("@UserCompanyDetail",objUserBO.UserCompanyDetail) ,
                    new SqlParameter("@LanguageList",objCandidateMasterBO.LanguageList), 
                    new SqlParameter("@CandidateIDRegisterd",cid),
                    new SqlParameter("@ProCurrentRole",objUsersQualificationBO.ProCurrentRole),
                    new SqlParameter("@ProExperience,",objUsersQualificationBO.ProExperience),
                    new SqlParameter("@ProfQualitative1",objUsersQualificationBO.ProfQualitative1),
                    new SqlParameter("@ProfQualitative2,",objUsersQualificationBO.ProfQualitative2),
                    new SqlParameter("@ProfQualitative3,",objUsersQualificationBO.ProfQualitative3),
                    new SqlParameter("@ProfQualitative4,",objUsersQualificationBO.ProfQualitative4),

                    new SqlParameter("@UserRegID",g) 

                };

                return DataUtils.ExecuteScalar("Usp_EditRegisterdCandidateMaster", parameters);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }


        public DataSet GetCandidateDetailsByEmailID(params object[] param)
        {
            DataSet objDs;


            try
            {
                objDs = DataUtils.ExecuteDataset("USP_GetUserDetailByEmail", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public string GetPasswordByEmail(params object[] param)
        {
            string result;

            try
            {
                result = DataUtils.ExecuteScalar("USP_GetPasswordByEmail", param).ToString();

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return result;
        }

        public string GetErrorMessage(MembershipCreateStatus status)
        {
            switch (status)
            {
                case MembershipCreateStatus.DuplicateUserName:
                    return "Username already exists. Please enter a different user name.";

                case MembershipCreateStatus.DuplicateEmail:
                    return "A username for that e-mail address already exists. Please enter a different e-mail address.";

                case MembershipCreateStatus.InvalidPassword:
                    return "The password provided is invalid. Please enter a valid password value.";

                case MembershipCreateStatus.InvalidEmail:
                    return "The e-mail address provided is invalid. Please check the value and try again.";

                case MembershipCreateStatus.InvalidAnswer:
                    return "The password retrieval answer provided is invalid. Please check the value and try again.";

                case MembershipCreateStatus.InvalidQuestion:
                    return "The password retrieval question provided is invalid. Please check the value and try again.";

                case MembershipCreateStatus.InvalidUserName:
                    return "The user name provided is invalid. Please check the value and try again.";

                case MembershipCreateStatus.ProviderError:
                    return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";

                case MembershipCreateStatus.UserRejected:
                    return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";

                default:
                    return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
            }
        }

        public DataSet GetUserDetails(Guid UserID)
        {
            DataSet objDs;
            try
            {
                objDs = DataUtils.ExecuteDataset("USP_GetUserDetails", UserID);
            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public string ChangeUserStatus(Guid UserID, string Email, string Status)
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
			    {   
                    new SqlParameter("@Email",Email),
                    new SqlParameter("@ModifyBy",UserID),
                    new SqlParameter("@Status",Status)
			    };

                string result = DataUtils.ExecuteScalar("USP_DeleteUsrMaster", parameters).ToString(); ;
                return result;

            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }

        public DataSet GetCandidatedeRegByUserId(Guid param)
        {
            DataSet objDs;

            try
            {
                objDs = DataUtils.ExecuteDataset("Usp_GetCandidateRegByUserId", param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public string GetActualUserName(Guid UserID)
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
			    {   
                    new SqlParameter("@UserID",UserID)
			    };

                string result = DataUtils.ExecuteScalar("USP_GetActualUserName", parameters).ToString(); ;
                return result;
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }

        public object UpdateAssessor(UserMasterBO param)
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
			    {      
                    
                    new SqlParameter("@UpdateUserID",param.UserID),
                    new SqlParameter("@FirstName",param.FirstName),
                    new SqlParameter("@MiddleName",param.MiddleName),
                    new SqlParameter("@LastName",param.LastName),
                    new SqlParameter("@ProfilePicturePath",param.ProfilePicturePath),
                    new SqlParameter("@Gender",param.Gender),
                    new SqlParameter("@DOB",param.DOB),
                    new SqlParameter("@CreatedBy",param.CreatedBy),
                    new SqlParameter("@ModifyBy",param.ModifyBy), 
                    new SqlParameter("@CountryID",param.CountryID),
                    new SqlParameter("@StateName",param.StateName),
                    new SqlParameter("@ContactAddress",param.Address),
                    new SqlParameter("@ZipCode",param.ZipCode),
                    new SqlParameter("@PhoneNo",param.WorkPhoneNo),
                    new SqlParameter("@MobileNo",param.MobileNo),
                    new SqlParameter("@OtherPhoneNo",param.OtherPhoneNo),
                    new SqlParameter("@GraduationID",param.Graduation),
                    new SqlParameter("@QualificationSpecialization",param.Specialization),
                    new SqlParameter("@University",param.University),
                    new SqlParameter("@QualificationStatusID",param.Status),
                    new SqlParameter("@Fees",param.Fees),
                    new SqlParameter("@PaymentMode",param.PaymentMode),
                    new SqlParameter("@BankName",param.BankName),
                    new SqlParameter("@BankCode",param.BankCode),
                    new SqlParameter("@SWIFTCode",param.SWIFTCode),
                    new SqlParameter("@AccountNo",param.AccountNo),
                    new SqlParameter("@UserCompanyDetail",param.UserCompanyDetail),                    
                   new SqlParameter("@ReturnValue",param.StatusMessage)
			    };

                object result = DataUtils.ExecuteScalar("Usp_UpdateAssessor", parameters).ToString(); ; //update parameter
                return result;

            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }

        public DataSet GetDeletedCandidate(string strEmailId,  string strDeletedType)
        {
            DataSet objDs;

            try
            {
                SqlParameter[] parameters = new SqlParameter[]
                {
                    new SqlParameter("@EmailId",strEmailId),
                    new SqlParameter("@DeletedType",strDeletedType)

                };
                objDs = DataUtils.ExecuteDataset("Usp_GetDeletedCandidate", parameters);
                return objDs;
            }
            catch (Exception ex)
            {

                throw new ApplicationException(ex.Message);
            }
        }

        public DataSet GetCandidateDetailsByRegNum(string strRegNum)
        {
            DataSet objDs;

            try
            {
                SqlParameter[] parameters = new SqlParameter[]
                {
                    new SqlParameter("@RegistrationNo",strRegNum)
                };
                objDs = DataUtils.ExecuteDataset("Usp_GetCandidateDetailByRegNo", parameters);
                return objDs;
            }
            catch (Exception ex)
            {

                throw new ApplicationException(ex.Message);
            }
        }

        public object DeleteCandidateByRegNum(long candID, Guid userid, string remarkbyadmin)
        {
            object objDs;
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
                {
                    new SqlParameter("@CandidateID",candID),
                    new SqlParameter("@UserID",userid),
                    new SqlParameter("@Remark",remarkbyadmin),
                    new SqlParameter("@DeletedDate",DateTime.Now)
                };
                objDs = DataUtils.ExecuteScalar("Usp_SetCandidateDelete", parameters);
                return objDs;
            }
            catch (Exception ex)
            {

                throw new ApplicationException(ex.Message);

            }
        }
        public object DeleteCandidatePhysical(string strregistrationId)
        {
            object objDs;
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
                {
                    new SqlParameter("@RegistrationNo",strregistrationId),
                    
                };
                objDs = DataUtils.ExecuteScalar("Usp_SetDeleteCandidatePhysical", parameters);
                return objDs;
            }
            catch (Exception ex)
            {

                throw new ApplicationException(ex.Message);

            }
        }
        public object DeleteCandidateAllocation(string strregistrationId)
        {
            object objDs;
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
                    {
                        new SqlParameter("@RegistrationNo",strregistrationId),
                    
                    };
                objDs = DataUtils.ExecuteScalar("Usp_SetDeleteCandidateAllocation", parameters);
                return objDs;
            }
            catch (Exception ex)
            {

                throw new ApplicationException(ex.Message);

            }
        }
        public void UpdateCandidateAssessorPayment(Guid pObjUser, int CandidateID)
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
                    {
                        new SqlParameter("@AssessorID",pObjUser),
                        new SqlParameter("@CandidateID",CandidateID),
                    
                    };
                DataUtils.ExecuteScalar("Usp_SetCandidateAssessorPayment", parameters);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);

            }
        }
    }
}
